/**
 * Copyright 2019 Inc.
 **/
package com.myz.demo;

import feign.Feign;
import feign.gson.GsonDecoder;
import feign.gson.GsonEncoder;

import java.util.List;

/**
 * http://techblog.ppdai.com/2018/05/15/20180515/
 * <p>
 * GsonDecoder依赖:Gson 包含了一个编码器和一个解码器，这个可以被用于JSON格式的API
 * <dependency>
 * <groupId>com.netflix.feign</groupId>
 * <artifactId>feign-gson</artifactId>
 * <version>8.18.0</version>
 * </dependency>
 *
 * @author maoyz0621 on 19-7-11
 * @version: v1.0
 */
public class GsonFeign {

    /**
     * 使用GsonDecoder()
     *
     * @param args
     */
    public static void main(String... args) {
        GitHub github = Feign.builder()
                .encoder(new GsonEncoder())
                .decoder(new GsonDecoder())
                .target(GitHub.class, "https://api.github.com");

        List<Contributor> contributors = github.contributors("OpenFeign", "feign");
        for (Contributor contributor : contributors) {
            System.out.println(contributor.login + " (" + contributor.contributions + ")");
        }
    }
}

class Credentials {

    final String user_name;
    final String password;

    Credentials(String user_name, String password) {
        this.user_name = user_name;
        this.password = password;
    }
}